home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: malloc question
- Date: 12 Mar 1996 20:20:06 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar12132006@qcd.lanl.gov>
- References: <4htonk$350@news.hklink.net> <4i492m$9jl@news1.warwick.net>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: acorn@warwick.net's message of Tue, 12 Mar 1996 16:35:35 GMT
-
- In article <4i492m$9jl@news1.warwick.net>
- acorn@warwick.net (Peter Kohlberger) writes:
- <snip>
- PK: Basically, you need the cast because head is of type "pointer to ITEM"
- PK: and malloc returns type "pointer to void". If you try it without the
- PK: cast, your compiler will complain "cannot convert *void to *ITEM".
-
- If it does, _you_ should complain vehemently. Whatever it is a
- compiler for, it is not for the language called C.
-
- PK: This is just the mechanics of the answer though, and I suspect this
- PK: is not what really puzzles you.
- PK:
- PK: Without the cast, you can not convert *void into *ITEM; with the cast,
-
- If you can create something called *void, you could probably also
- convert it to *ITEM :-)
-
- More seriously, please be careful when posting junk. C defines
- void* ---> ITEM* (for any data or incomplete type ITEM) conversion to be
- allowed cast free. A compiler can impotently complain its
- unwillingness to do so (and if it does, I shall drag the compiler to
- exactly where it belongs), but a C compiler cannot refuse to compile
- strictly conformant C code.
-
- PK: you are allowed to do the conversion. If the conversion is allowed in
- PK: one manner, why is it not allowed in the other manner?
-
- Your last statement suggests you have confused the two similar
- languages called C and C++.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-